/**
 * Project Name:renshuaipeng-auth
 * File Name:AuthPermissionService.java
 * Package Name:ren.renshuaipeng.auth.service.auth
 * Date:2015年12月20日 下午3:43:14
 * Copyright (c) 2015, niao.shuai123@163.com All Rights Reserved.
 */

package ren.renshuaipeng.auth.service.auth;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import ren.renshuaipeng.auth.dao.auth.AuthPermissionDao;
import ren.renshuaipeng.auth.domain.auth.AuthPermission;

/**
 * ClassName:  AuthPermissionService.java<br/>
 * Function: . <br/>
 * Date:      2015年12月20日 下午3:43:14<br/>
 *
 * @author 任帅鹏（作者）
 * @version V1.00 （版本号）
 * @see
 * @since JDK 1.8
 */
@Service
@Transactional(readOnly=true)
public class AuthPermissionService {

	@Autowired
	private AuthPermissionDao authPermissionDao;
	
	public List<AuthPermission> findAll(){
		return (List<AuthPermission>) authPermissionDao.findAllByParentIdIsNull();
		//return authPermissionDao.findAll();
	}
	
	@Transactional
	public AuthPermission save(AuthPermission authPermission) {
		return authPermissionDao.save(authPermission);
	}

	@Transactional
	public void delete(String id) {
		authPermissionDao.delete(id);
	}

	public Page<AuthPermission> findPage(Pageable pageable) {
		return authPermissionDao.findAll(pageable);
	}
	
	public AuthPermission findById(String id){
		return authPermissionDao.findOne(id);
	}
}
